package com.feihong.yw189.activity.WebInterface;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.webkit.JavascriptInterface;

import com.feihong.yw189.activity.dingdan.DingDanDetailsActivity;
import com.just.agentweb.AgentWeb;

import org.json.JSONObject;

/**
 * js交互接口
 * Created by PVer on 2018/1/4.
 */

public class OrderDetailWebInterface {

    private final String TAG = "营维189";
    private AgentWeb agent;
    private Context context;
    private DingDanDetailsActivity.ActionCallBack callBack;

    public OrderDetailWebInterface(AgentWeb agent, Context context, DingDanDetailsActivity.ActionCallBack callBack) {
        this.agent = agent;
        this.context = context;
        this.callBack = callBack;
    }

    private Handler deliver = new Handler(Looper.getMainLooper());

    /***
     * 扫码
     * @param json
     */
    @JavascriptInterface
    public void sao_iccid(String json) {
        try {
            JSONObject object = new JSONObject(json);
            String funcSuccess = object.getString("success");
            if (!TextUtils.isEmpty(funcSuccess)) {
                callBack.saoma(funcSuccess);
            }
        } catch (Exception ex) {
        }

    }

    //发送签名数据
    @JavascriptInterface
    public String getToken() {
        return callBack.getToken();
    }

    //发送签名数据
    @JavascriptInterface
    public String getSign(String info) {
        return callBack.sendSign(info);
    }

    /*-----------支付密码--------------*/
    @JavascriptInterface
    public String orderPay(String info) {
        return callBack.orderPay(info);
    }

    /*-----------照片补传--------------*/
    @JavascriptInterface
    public String setDzda(String info) {
        return callBack.setDzda(info);
    }

    /*-----------修改手机号--------------*/
    @JavascriptInterface
    public String setPhone(String info) {
        return callBack.setPhone(info);
    }

    /*-----------副卡--------------*/
    @JavascriptInterface
    public String get_phone(String info) {
        return callBack.get_phone(info);
    }

    /*-----------修改Iccid--------------*/
    @JavascriptInterface
    public String setIccid(String info) {
        return callBack.setIccid(info);
    }

    /*-----------获取宽副 iCCID号--------------*/
    @JavascriptInterface
    public String get_iccid(String info) {
        return callBack.get_iccid(info);
    }

    /*-----------修改座机号--------------*/
    @JavascriptInterface
    public String setTel(String info) {
        return callBack.setTel(info);
    }

    /*-----------手写签名--------------*/
    @JavascriptInterface
    public String setQianming(String info) {
        return callBack.setQianming(info);
    }

    /*-----------手写签名--------------*/
    @JavascriptInterface
    public String get_qianming(String info) {
        return callBack.get_qianming(info);
    }

    /*-----------预览照片--------------*/
    @JavascriptInterface
    public String images_zoom(String info) {
        return callBack.images_zoom(info);
    }

    /*-----------提交开户--------------*/
    @JavascriptInterface
    public String progress(String info) {
        return callBack.progress(info);
    }

    /**拍照*/
    @JavascriptInterface
    public Boolean get_images(String info){

        return callBack.get_images(info);
    }
}
